package com.citi.gts.galto.modules.validation.rule.impl;

import com.citi.gts.galto.core.tools.exception.ReferenceException;
import com.citi.gts.galto.core.tools.reference.Field;
import com.citi.gts.galto.modules.validation.exception.SubServiceException;
import com.citi.gts.galto.modules.validation.exception.ValidationException;
import com.citi.gts.galto.modules.validation.vo.SampleInstruction;

import java.util.HashSet;
import java.util.Set;

public class BranchInformedRule extends LeafRule {

    @Override
    public void validate(SampleInstruction instruction) throws SubServiceException, ValidationException {

        System.out.println("Within "+getClass().getSimpleName());

        if (null == instruction.getBeneBranchCode()) {

            throw new SubServiceException(repair, "Uninformed Beneficiary Branch Code");
        }

    }

    @Override
    public void setFieldsValidated() throws ReferenceException {

        Set<Field> fieldValidatedSet = new HashSet<Field>(1);
        fieldValidatedSet.add(fieldReference.find("beneBranchCode"));

        repair.setFieldSet(fieldValidatedSet);
    }
}
